@import './variables.scss';

// 全局样式重置
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
  font-size: $font-size-base;
  color: $text-color-primary;
  background-color: $background-color-base;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

// 链接样式
a {
  color: $primary-color;
  text-decoration: none;
  
  &:hover {
    color: lighten($primary-color, 10%);
  }
}

// 滚动条样式
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: $background-color-light;
  border-radius: $border-radius-base;
}

::-webkit-scrollbar-thumb {
  background: $border-color-base;
  border-radius: $border-radius-base;
  
  &:hover {
    background: $border-color-light;
  }
}

// 工具类
.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.text-ellipsis {
  @include text-ellipsis;
}

.flex-center {
  @include flex-center;
}

.flex-between {
  @include flex-between;
}

.clearfix {
  @include clearfix;
}

// 间距工具类
@each $prop in (margin, padding) {
  @each $size, $length in (xs: $spacing-xs, sm: $spacing-sm, md: $spacing-md, lg: $spacing-lg, xl: $spacing-xl, xxl: $spacing-xxl) {
    .#{str-slice($prop, 1, 1)}-#{$size} {
      #{$prop}: $length;
    }
    
    .#{str-slice($prop, 1, 1)}t-#{$size} {
      #{$prop}-top: $length;
    }
    
    .#{str-slice($prop, 1, 1)}r-#{$size} {
      #{$prop}-right: $length;
    }
    
    .#{str-slice($prop, 1, 1)}b-#{$size} {
      #{$prop}-bottom: $length;
    }
    
    .#{str-slice($prop, 1, 1)}l-#{$size} {
      #{$prop}-left: $length;
    }
    
    .#{str-slice($prop, 1, 1)}x-#{$size} {
      #{$prop}-left: $length;
      #{$prop}-right: $length;
    }
    
    .#{str-slice($prop, 1, 1)}y-#{$size} {
      #{$prop}-top: $length;
      #{$prop}-bottom: $length;
    }
  }
}

// 字体大小工具类
.text-xs {
  font-size: $font-size-xs;
}

.text-sm {
  font-size: $font-size-sm;
}

.text-base {
  font-size: $font-size-base;
}

.text-lg {
  font-size: $font-size-lg;
}

.text-xl {
  font-size: $font-size-xl;
}

.text-xxl {
  font-size: $font-size-xxl;
}

// 字体粗细工具类
.font-light {
  font-weight: $font-weight-light;
}

.font-normal {
  font-weight: $font-weight-normal;
}

.font-medium {
  font-weight: $font-weight-medium;
}

.font-bold {
  font-weight: $font-weight-bold;
}

// 颜色工具类
.text-primary {
  color: $primary-color;
}

.text-success {
  color: $success-color;
}

.text-warning {
  color: $warning-color;
}

.text-danger {
  color: $danger-color;
}

.text-info {
  color: $info-color;
}

.text-muted {
  color: $text-color-secondary;
}

// 背景颜色工具类
.bg-primary {
  background-color: $primary-color;
}

.bg-success {
  background-color: $success-color;
}

.bg-warning {
  background-color: $warning-color;
}

.bg-danger {
  background-color: $danger-color;
}

.bg-info {
  background-color: $info-color;
}

// 边框工具类
.border {
  border: 1px solid $border-color-base;
}

.border-top {
  border-top: 1px solid $border-color-base;
}

.border-right {
  border-right: 1px solid $border-color-base;
}

.border-bottom {
  border-bottom: 1px solid $border-color-base;
}

.border-left {
  border-left: 1px solid $border-color-base;
}

.border-none {
  border: none;
}

// 圆角工具类
.rounded {
  border-radius: $border-radius-base;
}

.rounded-sm {
  border-radius: $border-radius-small;
}

.rounded-lg {
  border-radius: $border-radius-large;
}

.rounded-full {
  border-radius: 50%;
}

// 阴影工具类
.shadow {
  box-shadow: $box-shadow-base;
}

.shadow-lg {
  box-shadow: $box-shadow-light;
}

.shadow-none {
  box-shadow: none;
}

// 动画工具类
.transition {
  transition: $transition-base;
}

.transition-fade {
  transition: $transition-fade;
}

.transition-slide {
  transition: $transition-slide;
}

// 显示/隐藏工具类
.hidden {
  display: none;
}

.invisible {
  visibility: hidden;
}

.visible {
  visibility: visible;
}

// 响应式显示/隐藏
@include respond-to(xs) {
  .hidden-xs {
    display: none;
  }
}

@include respond-to(sm) {
  .hidden-sm {
    display: none;
  }
}

@include respond-to(md) {
  .hidden-md {
    display: none;
  }
}

@include respond-to(lg) {
  .hidden-lg {
    display: none;
  }
}

// Element Plus 样式覆盖
.el-card {
  border: 1px solid $border-color-lighter;
  box-shadow: $box-shadow-light;
  
  .el-card__header {
    padding: $spacing-lg $spacing-xl;
    border-bottom: 1px solid $border-color-lighter;
    background-color: $background-color-light;
  }
  
  .el-card__body {
    padding: $spacing-xl;
  }
}

.el-table {
  .el-table__header-wrapper {
    th {
      background-color: $background-color-light;
      color: $text-color-regular;
      font-weight: $font-weight-medium;
      border-bottom: 1px solid $border-color-lighter;
    }
  }
  
  .el-table__row {
    &:hover > td {
      background-color: lighten($primary-color, 45%);
    }
  }
}

.el-pagination {
  .el-pagination__total,
  .el-pagination__jump {
    color: $text-color-regular;
  }
}

.el-menu {
  border-right: none;
  
  .el-menu-item {
    &:hover {
      background-color: lighten($primary-color, 45%);
    }
    
    &.is-active {
      background-color: lighten($primary-color, 40%);
      color: $primary-color;
    }
  }
  
  .el-submenu__title {
    &:hover {
      background-color: lighten($primary-color, 45%);
    }
  }
}

// 自定义组件样式
.page-container {
  padding: $spacing-xl;
  background-color: $background-color-lighter;
  min-height: calc(100vh - #{$header-height});
}

.search-form {
  margin-bottom: $spacing-xl;
  padding: $spacing-lg;
  background-color: $background-color-lighter;
  border-radius: $border-radius-base;
  box-shadow: $box-shadow-base;
}

.data-table {
  background-color: $background-color-lighter;
  border-radius: $border-radius-base;
  box-shadow: $box-shadow-base;
}

.status-tag {
  &.online {
    background-color: lighten($success-color, 40%);
    color: $success-color;
    border-color: lighten($success-color, 20%);
  }
  
  &.offline {
    background-color: lighten($danger-color, 40%);
    color: $danger-color;
    border-color: lighten($danger-color, 20%);
  }
  
  &.maintenance {
    background-color: lighten($warning-color, 40%);
    color: $warning-color;
    border-color: lighten($warning-color, 20%);
  }
}